import { ApiProperty } from '@nestjs/swagger';
import { Column, Entity } from 'typeorm';
import { BaseEntity } from '../../../base.entity';

@Entity({ name: 'gather_machine' })
export default class GatherMachine extends BaseEntity {
  @Column({ type: 'varchar', length: 50, name: 'access_code', unique: true, comment: '接入编码' })
  @ApiProperty()
  accessCode: string;

  @Column({ type: 'varchar', length: 50, name: 'access_name', comment: '接入名称' })
  @ApiProperty()
  accessName: string;

  @Column({ type: 'varchar', length: 50, name: 'machine_code', comment: '设备编码' })
  @ApiProperty()
  machineCode: string;

  @Column({ type: 'varchar', length: 50, name: 'connect_type', comment: '连接类型' })
  @ApiProperty()
  connectType: string;

  @Column({ type: 'float', name: 'connect_read_time', comment: '获取数据间隙（ms）' })
  @ApiProperty()
  connectReadTime: number;

  @Column({ type: 'float', name: 'connect_over_time', comment: '获取数据超时时间（ms）' })
  @ApiProperty()
  connectOverTime: number;

  @Column({ type: 'float', name: 're_connect_num', comment: '连接失败重连次数' })
  @ApiProperty()
  reConnectNum: number;

  @Column({
    type: 'varchar',
    length: 50,
    name: 'connection_type',
    comment: 'modbus连接类型',
    nullable: true,
  })
  @ApiProperty()
  connectionType: string;

  @Column({ type: 'varchar', length: 50, name: 'ip', nullable: true, comment: 'IP' })
  @ApiProperty()
  ip: string;

  @Column({ type: 'varchar', length: 50, name: 'port', nullable: true, comment: '端口' })
  @ApiProperty()
  port: string;

  @Column({ type: 'varchar', length: 50, name: 'path', nullable: true, comment: '串口名' })
  @ApiProperty()
  path: string;

  @Column({ type: 'float', name: 'baud_rate', nullable: true, comment: '波特率' })
  @ApiProperty()
  baudRate: number;

  @Column({ type: 'float', name: 'data_bits', nullable: true, comment: '数据位' })
  @ApiProperty()
  dataBits: number;

  @Column({ type: 'float', name: 'auto_open', nullable: true, comment: '自动连接' })
  @ApiProperty()
  autoOpen: number;

  @Column({ type: 'float', name: 'stop_bits', nullable: true, comment: '停止位' })
  @ApiProperty()
  stopBits: number;

  @Column({ type: 'varchar', length: 50, name: 'parity', nullable: true, comment: '奇偶校验' })
  @ApiProperty()
  parity: string;

  @Column({ type: 'varchar', length: 50, name: 'protocol', nullable: true, comment: '协议' })
  @ApiProperty()
  protocol: string;

  @Column({ type: 'varchar', length: 50, name: 'host', nullable: true, comment: '主机' })
  @ApiProperty()
  host: string;

  @Column({ type: 'float', name: 'rack', nullable: true, comment: '机架' })
  @ApiProperty()
  rack: number;

  @Column({ type: 'float', name: 'slot', nullable: true, comment: '插槽' })
  @ApiProperty()
  slot: number;

  @Column({ type: 'varchar', length: 50, name: 'user_name', nullable: true, comment: '用户名' })
  @ApiProperty()
  userName: string;

  @Column({ type: 'varchar', length: 50, name: 'password', nullable: true, comment: '密码' })
  @ApiProperty()
  password: string;

  @Column({ type: 'float', name: 'is_open_multi_line', nullable: true, comment: '多线程采集' })
  @ApiProperty()
  isOpenMultiLine: number;

  @Column({ type: 'varchar', nullable: true, comment: '备注' })
  @ApiProperty()
  remark: string;
}
